package hust.music.action;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import hust.music.action.base.ActionBase;
import hust.music.entity.User;
import hust.music.service.UserModService;

/**
 * UpdateUserAction
 * 
 * @author Txazo
 * @since 1.0
 */
@Controller
@Scope("session")
public class UpdateUserAction extends ActionBase {

	private static final long serialVersionUID = 1L;

	private String nickname;
	private String introduce;
	private String sex;

	private String tip1;
	private String tip2;
	private String tip3;

	@Autowired
	private UserModService userModService;

	/**
	 * 修改个人资料
	 * 
	 * @return 逻辑视图
	 * @throws Exception
	 */
	public String update() throws Exception {
		if (nickname != null && !nickname.equals("")) {
			if (introduce != null && !introduce.equals("")) {
				User user = (User) session.get("user");
				user.setNickname(nickname);
				user.setIntroduce(introduce);
				user.setSex(sex);

				userModService.update(user);
				session.put("user", user);
				tip3 = "恭喜你成功修改个人资料";
				return SUCCESS;
			}
			tip2 = "请输入个人签名";
			return SUCCESS;
		}
		tip1 = "请输入昵称";
		if (introduce != null && !introduce.equals("")) {
		}
		tip2 = "请输入个人签名";
		return SUCCESS;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getIntroduce() {
		return introduce;
	}

	public void setIntroduce(String introduce) {
		this.introduce = introduce;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getTip1() {
		return tip1;
	}

	public void setTip1(String tip1) {
		this.tip1 = tip1;
	}

	public String getTip2() {
		return tip2;
	}

	public void setTip2(String tip2) {
		this.tip2 = tip2;
	}

	public String getTip3() {
		return tip3;
	}

	public void setTip3(String tip3) {
		this.tip3 = tip3;
	}

}